package 力扣._2605_从两个数字数组里生成最小数字;

import java.util.HashSet;
import java.util.Set;

public class Solution {
    public int minNumber(int[] nums1, int[] nums2) {
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set2 = new HashSet<>();
        for (int i : nums1) {
            set1.add(i);
        }
        for (int i : nums2) {
            set2.add(i);
        }
        for (int i = 1; i < 10; i++) {
            if (set1.contains(i) && set2.contains(i))
                return i;
        }
        for (int i = 10; i < 100; i++) {
            int a = i / 10;
            int b = i % 10;
            if (set1.contains(a) && set2.contains(b))
                return i;
            if (set1.contains(b) && set2.contains(a))
                return i;
        }
        return -1;

    }

    public static void main(String[] args) {

    }
}
